# NOTE: This must be BUILD.bazel (not BUILD) because otherwise, you can't
# build python packages in this directory (which creates "build" directories)
# on case-inensitive file systems.
package(
    default_visibility = ["//visibility:public"],
    features = ["layering_check"],
    licenses = ["notice"],
)

# Allow all python sources to be built externally.
exports_files(glob([
    "python/*.cpp",
    "python/*.c",
    "python/**/*.py",
    "unittests/**/*.py",
]))

################################################################################
# Package-by-package filegroup exports.
# Some tools can make use of such non-nested groups.
################################################################################

filegroup(
    name = "python_compiler_tools",
    srcs = glob(["python/iree/compiler/tools/*.py"]),
)

filegroup(
    name = "python_compiler_tools_deprecated_redirects",
    srcs = [
        "python/iree/compiler/__init__.py",
        "python/iree/compiler/tf.py",
        "python/iree/compiler/tflite.py",
        "python/iree/compiler/xla.py",
    ],
)

filegroup(
    name = "python_compiler_api",
    srcs = glob(["python/iree/compiler/api/*.py"]),
)

filegroup(
    name = "unittests_tools_testdata",
    srcs = glob([
        "unittests/tools/testdata/*",
    ]),
)

################################################################################
# CAPI
################################################################################

cc_library(
    name = "CAPI",
    srcs = [
        "lib/CAPI/Compiler.cpp",
        "lib/CAPI/Lld.cpp",
        "lib/CAPI/Tools.cpp",
    ],
    hdrs = [
        "include/iree-compiler-c/Compiler.h",
        "include/iree-compiler-c/Tools.h",
    ],
    includes = ["include"],
    deps = [
        "//iree/compiler/Dialect/VM/IR",
        "//iree/compiler/Dialect/VM/Target/Bytecode",
        "//iree/compiler/Translation:IREEVM",
        "//iree/tools:init_targets",
        "//iree/tools:iree_translate_lib",
        "@llvm-project//lld:COFF",
        "@llvm-project//lld:Common",
        "@llvm-project//lld:ELF",
        "@llvm-project//lld:MachO",
        "@llvm-project//lld:Wasm",
        "@llvm-project//llvm:Support",
        "@llvm-project//mlir:CAPIIR",
        "@llvm-project//mlir:IR",
    ],
)
